package aaa.question.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import aaa.common.annotation.Log;
import aaa.common.core.controller.BaseController;
import aaa.common.core.domain.AjaxResult;
import aaa.common.enums.BusinessType;
import aaa.question.domain.BruExamSimulationBank;
import aaa.question.service.IBruExamSimulationBankService;
import aaa.common.utils.poi.ExcelUtil;
import aaa.common.core.page.TableDataInfo;

/**
 * 真题管理Controller
 * 
 * @author xyy
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/exam/exam")
public class BruExamSimulationBankController extends BaseController
{
    @Autowired
    private IBruExamSimulationBankService bruExamSimulationBankService;

    /**
     * 查询真题管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:exam:list')")
    @GetMapping("/list")
    public TableDataInfo list(BruExamSimulationBank bruExamSimulationBank)
    {
        startPage();
        List<BruExamSimulationBank> list = bruExamSimulationBankService.selectBruExamSimulationBankList(bruExamSimulationBank);
        return getDataTable(list);
    }

    /**
     * 导出真题管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:exam:export')")
    @Log(title = "真题管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BruExamSimulationBank bruExamSimulationBank)
    {
        List<BruExamSimulationBank> list = bruExamSimulationBankService.selectBruExamSimulationBankList(bruExamSimulationBank);
        ExcelUtil<BruExamSimulationBank> util = new ExcelUtil<BruExamSimulationBank>(BruExamSimulationBank.class);
        util.exportExcel(response, list, "真题管理数据");
    }

    /**
     * 获取真题管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:exam:query')")
    @GetMapping(value = "/{examId}")
    public AjaxResult getInfo(@PathVariable("examId") Long examId)
    {
        return success(bruExamSimulationBankService.selectBruExamSimulationBankByExamId(examId));
    }

    /**
     * 新增真题管理
     */
    @PreAuthorize("@ss.hasPermi('exam:exam:add')")
    @Log(title = "真题管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BruExamSimulationBank bruExamSimulationBank)
    {
        return toAjax(bruExamSimulationBankService.insertBruExamSimulationBank(bruExamSimulationBank));
    }

    /**
     * 修改真题管理
     */
    @PreAuthorize("@ss.hasPermi('exam:exam:edit')")
    @Log(title = "真题管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BruExamSimulationBank bruExamSimulationBank)
    {
        return toAjax(bruExamSimulationBankService.updateBruExamSimulationBank(bruExamSimulationBank));
    }

    /**
     * 删除真题管理
     */
    @PreAuthorize("@ss.hasPermi('exam:exam:remove')")
    @Log(title = "真题管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examIds}")
    public AjaxResult remove(@PathVariable Long[] examIds)
    {
        return toAjax(bruExamSimulationBankService.deleteBruExamSimulationBankByExamIds(examIds));
    }
}
